package gamecode;

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;

public class EntityManager {

	private List<Entity> entities;
	
	public EntityManager() {
		entities = new ArrayList<Entity>();
	}
	
	public void addEntity(Entity e) {
		entities.add(e);
	}
	
	public boolean removeEntity(Entity e) {
		return entities.remove(e);
	}
	
	public void drawEntities(Graphics2D g2d, Rectangle bounds, EntityPlayerShip player) {
		for (Entity e : entities) {
			try {
				e.drawEntity(g2d, bounds, player);
			}
			catch (Exception ex) {
				System.out.println("Error drawing an entity: " + ex.getMessage());
			}
		}
	}
}
